package com.edu.order.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.edu.entity.HfdLocInfo;
import com.edu.order.service.IHfdLocInfoService;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 地址表 前端控制器
 * </p>
 *
 * @author jr
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/order/loc")
public class HfdLocInfoController {

    @Autowired
    private IHfdLocInfoService hfdLocInfoService;

    //查询地址
    @RequestMapping("findLoc")
    public Result findLoc(){
       return hfdLocInfoService.findLoc();
    }

    //添加地址
    @RequestMapping("addLoc")
    public Result addLoc(@RequestBody HfdLocInfo hfdLocInfo){

        return hfdLocInfoService.addLoc(hfdLocInfo);
    }

    //修改地址
    @RequestMapping("editAddress")
    public Result editAddress(@RequestBody HfdLocInfo hfdLocInfo){
        boolean b = hfdLocInfoService.updateById(hfdLocInfo);

        return new Result(b,b?90021:90020,b?"success":"fail");
    }

    //删除地址
    @RequestMapping("deleteAddress")
    public Result deleteAddress(Integer locId){
        return hfdLocInfoService.deleteAddress(locId);
    }

}
